<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=no,width=device-width,initial-scale=1.0"/>
    <title>jqlongtap</title>
</head>
<body>

<div class="long">测试</div>
<div class="long">测试</div>
<div class="long">测试</div>
<div class="long">测试</div>

<script src="jquery-3.1.1.min.js"></script>
<script>
    /**
     * 拓展jquery插件方法 长按事件
     */
    jQuery.fn.extend({
        longTap: function (cb) {
            var longtimer;
            $(this).on('touchstart', function (e) {
                e.stopPropagation();
                longtimer = setTimeout(function () {
                    cb();
                }, 750);//这里设置长按响应时间
            });
            $(this).on('touchend', function (e) {
                e.stopPropagation();
                clearTimeout(longtimer);
            });
            $(this).on('touchmove', function (e) {
                e.stopPropagation();
                clearTimeout(longtimer);
            });
            $(this).on('touchcancel', function (e) {
                e.stopPropagation();
                clearTimeout(longtimer);
            });
        }
    });
</script>
<script>
    $(".long").longTap(function () {
        console.log("长按了")
    });
</script>
</body>
</html>